We linked data on discharge diagnoses from hospitals in Sweden and Denmark with comprehensive cancer and mortality registry data in those countries to determine risks of cancer following uncommon diagnoses. Studies of connective tissue disorders revealed that patients with polymyositis and dermatomyositis had increased risk of cancer of the lung, ovary, hematopoietic and lymphatic systems in the first two years of follow-up, but risks declined sharply thereafter. Thus, extensive screening of such patients is not required after two years. Patients with systemic sclerosis had increased risk of lung and non-melanoma skin cancer, compared to patients with localized scleroderma. Patients undergoing tonsillectomy after age 20 were at increased risk of non-Hodgkin's lymphoma, while those tonsillectomized before age 12 had increased risk of Hodgkin's disease. Splenectomy following trauma was not associated with increased cancer risk, whereas splenectomy used as treatment for other conditions was associated with increased lung cancer risk, possibly related to smoking. We confirmed that patients with pernicious anemia had elevated risk of cancer of the stomach and upper digestive tract. Patients with a diagnosis of gastric ulcer were found to have elevated gastric cancer risk, whereas patients with duodenal ulcer had reduced gastric cancer risk. Patients with diabetes had persistently elevated risks of cancers of the liver and pancreas, and patients with hemochromatosis had a cumulative risk of hepatic cancer of 10% after about nine years. Patients with endometriosis had increased risks of non-Hodgkin's lymphoma and breast and ovarian cancers but no increased risk of cervical or endometrial cancer.